<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>审核通知</title>
    <#assign base=request.contextPath  />
    <base id="basePath" href="${base}">
    <link rel="stylesheet" href="${base}/frame/layui/css/layui.css" media="all">
    <script src="${base}/frame/layui/layui.js" charset="utf-8"></script>
    <script src="${base}/js/jquery.min.js"></script>
    <style type="text/css">
        .layui-btn-radius {
            border-radius: 5px;
        }

    </style>
</head>
<body>
<form method="get" action="" id="myform" class="layui-form">
    <input type="hidden" id="id" value="${order.id}"/>
    <input type="hidden" id="userId"  value="${order.userId}"/>
    <input type="hidden" id="userList"  value="${order.userList}"/>
    <input type="hidden" id="orderNumber"  value="${order.orderNumber}"/>
    <input type="hidden" id="noticeId"  value="${order.noticeId}"/>

    <br>


    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">内容</label>
            <div class="layui-input-inline">
                <textarea name="content" id="content" disabled value="" style="height: 200px;" lay-verify="required" autocomplete="off"
                          class="layui-input" type="text">${order.content}</textarea>
            </div>
        </div>
    </div>



    <div class="layui-form-item">
        <label class="layui-form-label">价格</label>
        <div class="layui-input-inline">
        <#--<input type="radio" name="order" lay-filter="orderMoeny"  id="moeny" value="1" title="1元">-->
        <#--<input type="radio" name="order" lay-filter="orderMoeny"  id="moeny" value="5" title="5元">-->
        <#--<input type="radio" name="order" lay-filter="orderMoeny"  id="moeny" value="10" title="10元">-->
        <#--<input type="radio" name="order" lay-filter="orderMoeny"  id="moeny" value="20" title="20元">-->
        <#--<input type="radio" name="order" lay-filter="orderMoeny"  id="moeny" value="30" title="30元">-->
        <#--<input type="radio" name="order" lay-filter="orderMoeny"  id="moeny" value="50" title="50元">-->
            <button type="button" style="width: 50px;height: 50px;" id="1" onclick="moeny(this,1)">1元</button>
            <button type="button" style="width: 50px;height: 50px;" id="5" onclick="moeny(this,5)">5元</button>
            <button type="button" style="width: 50px;height: 50px;" id="10" onclick="moeny(this,10)">10元</button>
            <button type="button" style="width: 50px;height: 50px;" id="20" onclick="moeny(this,20)">20元</button>
            <button type="button" style="width: 50px;height: 50px;" id="30" onclick="moeny(this,30)">30元</button>
            <button type="button" style="width: 50px;height: 50px;" id="50" onclick="moeny(this,50)">50元</button>


        </div>
    </div>

    <div class="layui-form-item">
    <div class="layui-inline">
        <label class="layui-form-label">自定义</label>
        <div class="layui-input-inline">
            <input name="orderMoeny" id="orderMoeny"  autocomplete="off"
                   class="layui-input" type="text">
        </div>
    </div>
    </div>


    <div id="msg" style="display:none;" ></div>



    <div class="layui-form-item" style="text-align:center">
        <div class="layui-inline">
            <button class="layui-btn layui-btn-radius" lay-submit lay-filter="formDemo" type="button"
                  id="onSubmit" style="background-color: #28B779;">通过
            </button>
            <button class="layui-btn layui-btn-radius" id="error" lay-submit lay-filter="formDemo" type="button"  style="background-color: red">不通过</button>
        </div>
    </div>
</form>
<script>
    function handle() {
        document.getElementById('msg').innerHTML = "输入的文字为：" + document.getElementById('orderMoeny').value;
        if(
                document.getElementById('orderMoeny').value!=1 &&
                document.getElementById('orderMoeny').value!=5 &&
                document.getElementById('orderMoeny').value!=10 &&
                document.getElementById('orderMoeny').value!=20 &&
                document.getElementById('orderMoeny').value!=30 &&
                document.getElementById('orderMoeny').value!=50
        ){
            document.getElementById(1).style.backgroundColor = "";
            document.getElementById(5).style.backgroundColor = "";
            document.getElementById(10).style.backgroundColor = "";
            document.getElementById(20).style.backgroundColor = "";
            document.getElementById(30).style.backgroundColor = "";
            document.getElementById(50).style.backgroundColor = "";
        }
    }
    if(/msie/i.test(navigator.userAgent)) {   //ie浏览器
        //console.log("ie浏览器")
        //document.getElementById('txt').onpropertychange = handle;
        document.getElementById('orderMoeny').attachEvent("onpropertychange", handle);
    }
    else {//非ie浏览器，比如Firefox
        //console.log("非ie浏览器")
        document.getElementById('orderMoeny').addEventListener("input", handle, false);
        //document.getElementById('txt').watch('a', fn);
    }

</script>
<script>

    layui.use(['form', 'layedit', 'laydate', 'table', 'carousel'], function () {

        var carousel = layui.carousel;
        var form = layui.form
            , $ = layui.jquery
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate
            , table = layui.table;

    });


</script>
<script>


    //通过
    $("#onSubmit").one("click",function(){

        if(document.getElementById("1").value=="" &&
                document.getElementById("5").value=="" &&
                document.getElementById("10").value=="" &&
                document.getElementById("20").value=="" &&
                document.getElementById("30").value=="" &&
                document.getElementById("50").value==""){
            if($("#orderMoeny").val()==""){
                layer.msg("金额不能为空或选择常用金额")
                return;
            }
        }

        var reg = /^\d+$|^\d*\.\d+$/g;
        if(!reg.test($("#orderMoeny").val())){
            layer.msg("金额不合法")
            return;
        }

        if( $("#orderMoeny").val()==0){
            layer.msg("金额不能为 0")
            return;
        }

        // if( $("#orderMoeny").val()<5){
        //     layer.msg("金额不能小于5元")
        //     return;
        // }


        // if($('input:radio[name="orderMoeny"]:checked').val()==undefined){
        //     if($("#orderMoeny").val()==""){
        //         layer.msg("金额不能为空或选择常用金额")
        //         return;
        //     }
        // }


        var jsonDate = {};
        jsonDate.id = $("#id").val();
        jsonDate.userId = $("#userId").val();
        jsonDate.content = $("#content").val();
        jsonDate.userList = $("#userList").val();
        jsonDate.noticeId = $("#noticeId").val();
        jsonDate.orderNumber = $("#orderNumber").val();
        // if($('input:radio[name="orderMoeny"]:checked').val()==undefined){
        //     jsonDate.orderMoeny = $("#orderMoeny").val()*100;
        // }else{
        //     jsonDate.orderMoeny = $('input:radio[name="orderMoeny"]:checked').val()*100;
        // }
        if(document.getElementById("1").value=="" &&
                document.getElementById("5").value=="" &&
                document.getElementById("10").value=="" &&
                document.getElementById("20").value=="" &&
                document.getElementById("30").value=="" &&
                document.getElementById("50").value==""){
            jsonDate.orderMoeny = $("#orderMoeny").val()*100;

        }else{
            jsonDate.orderMoeny = document.getElementById("1").value*100;
            jsonDate.orderMoeny = document.getElementById("5").value*100;
            jsonDate.orderMoeny = document.getElementById("10").value*100;
            jsonDate.orderMoeny = document.getElementById("20").value*100;
            jsonDate.orderMoeny = document.getElementById("30").value*100;
            jsonDate.orderMoeny = document.getElementById("50").value*100;
        }

        $.ajax({
            type: "POST", //提交方式
            contentType: "application/json;charset=UTF-8",
            url: "${base}/admin/noticeOrder/success",
            data: JSON.stringify(jsonDate) ,
            success: function (data) {
                if (data.code === 0) {
                    layer.msg(data.msg)
                    setTimeout(function () {
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    }, 500)
                    var table = parent.layui.table;
                    //表刷新方法
                    table.reload('testReload', {
                        url: '${base}/admin/noticeOrder/selectMyPage'//数据接口
                        , where: {} //设定异步数据接口的额外参数
                    });
                } else {
                    layer.msg(data.msg)
                }
            }
        });
    })

    $("#error").one("click",function(){
        var jsonDate = {};
        jsonDate.id = $("#id").val();
        jsonDate.userId = $("#userId").val();
        jsonDate.noticeId = $("#noticeId").val();
        jsonDate.content = $("#content").val();
        $.ajax({
            type: "POST", //提交方式
            contentType: "application/json;charset=UTF-8",
            url: "${base}/admin/noticeOrder/error",
            data: JSON.stringify(jsonDate),
            success: function (data) {
                if (data.code === 0) {
                    layer.msg(data.msg)
                    setTimeout(function () {
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    }, 500)
                    var table = parent.layui.table;
                    //表刷新方法
                    table.reload('testReload', {
                        url: '${base}/admin/noticeOrder/selectMyPage'//数据接口
                        , where: {} //设定异步数据接口的额外参数
                    });
                } else {
                    layer.msg(data.msg)
                }
            }
        });
    })


    function moeny(_this,moeny) {
        var btn = $(_this);
        var button_val = btn.html();

        if(moeny==1){
            document.getElementById(1).style.backgroundColor = "#28B779";
            document.getElementById(5).style.backgroundColor = "";
            document.getElementById(10).style.backgroundColor = "";
            document.getElementById(20).style.backgroundColor = "";
            document.getElementById(30).style.backgroundColor = "";
            document.getElementById(50).style.backgroundColor = "";
        }
        if(moeny==5){
            document.getElementById(1).style.backgroundColor = "";
            document.getElementById(5).style.backgroundColor = "#28B779";
            document.getElementById(10).style.backgroundColor = "";
            document.getElementById(20).style.backgroundColor = "";
            document.getElementById(30).style.backgroundColor = "";
            document.getElementById(50).style.backgroundColor = "";
        }
        if(moeny==10){
            document.getElementById(1).style.backgroundColor = "";
            document.getElementById(5).style.backgroundColor = "";
            document.getElementById(10).style.backgroundColor = "#28B779";
            document.getElementById(20).style.backgroundColor = "";
            document.getElementById(30).style.backgroundColor = "";
            document.getElementById(50).style.backgroundColor = "";
        }
        if(moeny==20){
            document.getElementById(1).style.backgroundColor = "";
            document.getElementById(5).style.backgroundColor = "";
            document.getElementById(10).style.backgroundColor = "";
            document.getElementById(20).style.backgroundColor = "#28B779";
            document.getElementById(30).style.backgroundColor = "";
            document.getElementById(50).style.backgroundColor = "";
        }
        if(moeny==30){
            document.getElementById(1).style.backgroundColor = "";
            document.getElementById(5).style.backgroundColor = "";
            document.getElementById(10).style.backgroundColor = "";
            document.getElementById(20).style.backgroundColor = "";
            document.getElementById(30).style.backgroundColor = "#28B779";
            document.getElementById(50).style.backgroundColor = "";
        }
        if(moeny==50){
            document.getElementById(1).style.backgroundColor = "";
            document.getElementById(5).style.backgroundColor = "";
            document.getElementById(10).style.backgroundColor = "";
            document.getElementById(20).style.backgroundColor = "";
            document.getElementById(30).style.backgroundColor = "";
            document.getElementById(50).style.backgroundColor = "#28B779";
        }
        var re1 = /(\d{1,3})+(?:\.\d+)?/g
        var cc =  button_val.match(re1);
        document.getElementById("orderMoeny").value = cc;
    }


</script>

</body>
</html>